package fichier;

public class Entree extends Mouvement {
	
	protected Lieu provenance;
	protected LieuBox box;
	private static final String table = "arrive";
	
	public Entree(Modele modele, Lieu provenance, LieuBox box, String date){
		super();
		this.modele = modele;
		this.provenance = provenance;
		this.box = box;
		this.dateMouvement = date;
		this.modele.setEmplacement(this.box.box);
		this.ajouter();
		this.modele.update();
	}
	
	private void ajouter(){
		
		SelectData.REQUETE  = "INSERT INTO "+ table +" VALUES (null, "+this.modele.getID()+", '"+
														this.dateMouvement+"', '"+
														this.getProvenance().getLibelle() +"')";
		System.out.println(SelectData.REQUETE);
		SelectData.startUpdate();
	}
	
	public void supprimer(){
		SelectData.REQUETE = "DELETE FROM "+ table +" WHERE id_modele ="+this.modele.getID()+
							" and date_modele = '"+this.dateMouvement+"'";
		System.out.println(SelectData.REQUETE);
		SelectData.startUpdate();
	}
	
	public Lieu getProvenance() {
		return provenance;
	}
	public LieuBox getBox() {
		return box;
	}
	public void setProvenance(Lieu provenance) {
		this.provenance = provenance;
	}
	public void setBox(LieuBox box) {
		this.box = box;
	}

}
